package ar.com.cooker.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
 * Objeto BO Receta.
 * @author c02536
 *
 */
@Entity
@Table(name = "ck_Recipe")
public class Recipe implements Serializable {

	private static final long serialVersionUID = 9143134847775600234L;

	@Id
	@GeneratedValue
	@Column(name = "id_recipe")
	private Integer id;
	
	@Column(length = 100)	
	private String summary;
	
	@Column(length = 100)
	private String commensals;
	
	@Column(length = 50)
	private String tittle;
	
	@ManyToOne(targetEntity = RecipeType.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "id_recipe_type_fk", referencedColumnName = "id_recipe_type", nullable = false)
	private RecipeType recipeType;
	
	@ManyToOne(targetEntity = Region.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "id_proveniece_fk", referencedColumnName = "id_proveniece", nullable = true)
	private Region region;
	
	@ManyToOne(targetEntity = User.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "id_user_fk", referencedColumnName = "id_user", nullable = false)
	private User user;

	@ManyToOne(targetEntity = Dificulty.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "id_dificulty_fk", referencedColumnName = "id_dificulty", nullable = true)
	private Dificulty dificulty;
	
	@Column(name = "creation_date",length = 100)
	private Date creationDate;
	
	@OneToMany(targetEntity = Step.class,fetch = FetchType.LAZY, cascade = (CascadeType.REMOVE))
	@JoinColumn(name="id_recipe_fk")
	private Set<Step> steps;
	
	@OneToMany(targetEntity = File.class,fetch = FetchType.LAZY,cascade = (CascadeType.REMOVE))
	@JoinColumn(name = "id_recipe_fk")
	private Set<File> files;
	
	@ManyToOne(targetEntity = Origin.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "id_origin_fk", referencedColumnName = "id_origin", nullable = true)
	private Origin origin;
	
	@ManyToOne(targetEntity=Language.class,fetch = FetchType.EAGER)
	@JoinColumn(name = "id_language_fk",referencedColumnName = "id_language",nullable = false)
	private Language language;

	public Recipe() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getCommensals() {
		return commensals;
	}

	public void setCommensals(String commensals) {
		this.commensals = commensals;
	}

	public RecipeType getRecipeType() {
		return recipeType;
	}

	public void setRecipeType(RecipeType recipeType) {
		this.recipeType = recipeType;
	}

	public Region getRegion() {
		return region;
	}

	public void setRegion(Region region) {
		this.region = region;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}


	public void setDificulty(Dificulty dificulty) {
		this.dificulty = dificulty;
	}

	public Dificulty getDificulty() {
		return dificulty;
	}

	public void setTittle(String tittle) {
		this.tittle = tittle;
	}

	public String getTittle() {
		return tittle;
	}

	public void setSteps(Set<Step> steps) {
		this.steps = steps;
	}

	public Set<Step> getSteps() {
		return steps;
	}

	public void setFiles(Set<File> files) {
		this.files = files;
	}

	public Set<File> getFiles() {
		return files;
	}

	public void setOrigin(Origin origin) {
		this.origin = origin;
	}

	public Origin getOrigin() {
		return origin;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

	public Language getLanguage() {
		return language;
	}

	
}
